import operate from '@dfeidao/atom-nodejs/db/operate';


interface Message {
	ids: string[];
	productid: string;
	usercode: string[];
	username: string;
}

export default async function atom(msg: Message, action_id: string, session_id: string, spaceid: string) {
	const systemid = '12';
	const { del, exec } = operate(action_id, session_id, systemid);

	Array.from(msg.ids).forEach((v) => {
		del('pub_user', { _id: v, productid: msg.productid });
	});
	Array.from(msg.usercode).forEach((v) => {
		del('pub_user_connect', { usercode: v, productid: msg.productid });
	});
	const ret1 = await exec();

	if (ret1.code === 1) {
		return 'success';
	} else {
		return 'fail';
	}
}
